class BoxUI extends UIBase{
    private list:Array<any>= [1,1,1,1,1,1,1,1,1];
    private box_group:eui.Group;
    constructor(data?)
    {
        super('BoxView', data);
        this.touchChildren = true;
    }

    public init()
    {
        this.sendToSever(this.initUI,this);
    }

    public initUI(data?)
    {
        this.list = data;

        for(let i=0;i<9;i++)
        {
            let v = this.list[i];
            let boxItem = new BoxItemUI(v);
            boxItem.name = 'boxItem_' + i;
            this.box_group.addChild(boxItem);

            if(i < 3)
            {
                boxItem.y = 30;
                boxItem.x = 30 + i * 130;
            }
            else if(i < 6)
            {
                boxItem.y = 187;
                boxItem.x = 30 + (i - 3) * 130;
            }
            else
            {
                boxItem.y = 345;
                boxItem.x = 30 + (i - 6) * 130;
            }
        }
    }

    public sendToSever(call:Function, scope)
    {
        let openid = RoleCache.instance().openid ? RoleCache.instance().openid : '' ;
        let data = {
            openid:openid,
            version:GameConst.version
        }
        let self = this;
        UIManager.instance().showNormalLoading();
        HttpManager.instance().sendPost(GameConst.httpUrl + 'fishingaccs/get_navigate_list', StringUtil.jsonToHttpPostString(data), (e)=>{
            let data = JSON.parse(e);
            UIManager.instance().hideNormalLoading();
            if(data && data.data)
            {
                call.call(scope, data.data);
            }
        })
    }

    public clear()
    {
        super.clear();
    }   
}